package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.UserOtherBoundDao;
import com.tbit.uqbike.client.pojo.newEntity.UserOtherBound;
import com.tbit.uqbike.client.service.UserOtherBoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 11:29 2023/9/21
 */
@Service
public class UserOtherBoundServiceImpl implements UserOtherBoundService {

    @Autowired
    private UserOtherBoundDao userOtherBoundDao;

    @Override
    public void insert(UserOtherBound userOtherBound) {
        UserOtherBound userOtherBoundDB = getByUserId(userOtherBound.getUserId(), userOtherBound.getType());
        if (userOtherBoundDB == null) {
            userOtherBound.setUpdateTime(new Date());
            userOtherBoundDao.insert(userOtherBound);
        }
    }

    @Override
    public UserOtherBound getByUserId(Integer userId, Integer type) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("type", type);
        return userOtherBoundDao.getByUserId(map);
    }
}
